/***
 * im转发
 * @returns {Im}
 */
module.exports = () => {
    return async function Im(ctx, next) {
        let url = ctx.url;
        let method = ctx.method;

        let params = ctx.request.query;

        if ("POST" == method){
            params = ctx.request.body;
        }

        ctx.app.logger.info(url, method, params);
        //对url改写 替换掉
        url = url.replace('/guardian', '');
        ctx.app.logger.info(url);
        let data = await ctx.service.redirect.guardian({
            url,
            method,
            params
        });

        return ctx.body = data;

        await next();
    };
};
